import scrapy


class MeituSpider(scrapy.Spider):
    name = 'meitu'
    # allowed_domains = ['https://www.16pic.com/list/3-21-0-all-1.html']
    # start_urls = ['https://www.16pic.com/list/3-0-0-0_0_0_0_0_0-%d.html'% i for i in range(1,4)]
    i=2
    start_urls=['https://www.16pic.com/list/3-0-0-0_0_0_0_0_0-1.html']
    url='https://www.16pic.com/list/3-0-0-0_0_0_0_0_0-%d.html'

    def parse(self, response):
        print('开始解析页面')
        div_list=response.xpath('/html/body/div[3]/div[3]/div/div')
        print(len(div_list))
        for div in div_list:
            name=div.xpath('./div[2]/a/text()').extract_first()
        if self.i < 4:
            new_url=self.url % self.i
            self.i +=1
            yield scrapy.Request(url=new_url,callback=self.parse)



